package com.starleague.battletech.rules.movement;

import com.starleague.battletech.game.IMutableBattletechTeam;
import com.starleague.battletech.unit.BattletechUnitMovementType;
import com.starleague.battletech.unit.HasEngine;
import com.starleague.battletech.unit.IBattletechUnitEngine;
import com.starleague.battletech.unit.IMutableBattletechUnit;
import com.starleague.battletech.unit.IMutablePilot;
import com.starleague.battletech.unit.IWeight;
import com.starleague.battletech.unit.mech.HasMutableMechMovement;
import com.starleague.battletech.unit.mech.IMutableMech;
import com.starleague.battletech.unit.mech.MechMovementMode;
import com.starleague.hexagonal.IHexCoordinate;
import com.starleague.hexagonal.flat.FlatHexDirection;

class MechMovementState
        implements IMutableBattletechUnit, HasMutableMechMovement, HasEngine
{
    private final IMutableMech mech;
    private MechMovementMode movementMode;
    private IHexCoordinate hexCoordinate;
    private int elevation;
    private FlatHexDirection facingDirection;
    private int usedMovementPoints;

    MechMovementState(IMutableMech mech,
                      MechMovementMode movementMode)
    {
        this.mech = mech;
        this.movementMode = movementMode;
        this.hexCoordinate = mech.getHexCoordinate();
        this.elevation = mech.getElevation();
        this.facingDirection = mech.getFacingDirection();
        this.usedMovementPoints = mech.getUsedMovementPoints();
    }

    @Override
    public IMutablePilot getPilot()
    {
        return this.mech.getPilot();
    }

    @Override
    public void setPilot(IMutablePilot pilot)
    {
        this.mech.setPilot(pilot);
    }

    @Override
    public MechMovementMode getMovementMode()
    {
        return this.movementMode;
    }

    @Override
    public void setMovementMode(MechMovementMode movementMode)
    {
        this.movementMode = movementMode;
    }

    @Override
    public IHexCoordinate getHexCoordinate()
    {
        return this.hexCoordinate;
    }

    @Override
    public void setHexCoordinate(IHexCoordinate hexCoordinate)
    {
        this.hexCoordinate = hexCoordinate;
    }

    @Override
    public int getElevation()
    {
        return this.elevation;
    }

    @Override
    public void setElevation(int elevation)
    {
        this.elevation = elevation;
    }

    @Override
    public BattletechUnitMovementType getMovementType()
    {
        return this.mech.getMovementType();
    }

    @Override
    public boolean hasMoved()
    {
        return this.mech.hasMoved();
    }

    @Override
    public int getUsedMovementPoints()
    {
        return this.usedMovementPoints;
    }

    @Override
    public FlatHexDirection getFacingDirection()
    {
        return this.facingDirection;
    }

    @Override
    public void setFacingDirection(FlatHexDirection facingDirection)
    {
        this.facingDirection = facingDirection;
    }

    @Override
    public void setUsedMovementPoints(int usedMovementPoints)
    {
        this.usedMovementPoints = usedMovementPoints;
    }

    @Override
    public void clearMovement()
    {
        //
    }

    @Override
    public IWeight getWeight()
    {
        return this.mech.getWeight();
    }

    @Override
    public IBattletechUnitEngine getEngine()
    {
        return this.mech.getEngine();
    }

    @Override
    public IMutableBattletechTeam getTeam()
    {
        return this.mech.getTeam();
    }

    @Override
    public void setTeam(IMutableBattletechTeam team)
    {
        throw new RuntimeException("MechStateMovement: Team cannot be set");
    }
}
